
class Meme extends Entity {


// PARAMETERS
/*  final color colors[] = {
    color(255, 0, 0),
    color(0, 255, 0),
    color(0, 0, 255),
    color(255, 255, 0),
    color(255, 0, 255)
  };
*/
  final color colors[] = {
    color(232, 0, 108), // pink
    color(248, 234, 0), // yellow
    color(0, 159, 212) // blue
  };
  final color hilightColor = color(63);

  final float defaultMemeOpacity  = 30;
// END PARAMETERS


// MEMBERS
  int type;
  float spreadBonus;
  private int spreadCount;
  private Spring cloudPuller;
  private int numSpreaders;

  float drawOpacity;
// END MEMBERS

  public Meme() {
    super();
    init();
    spreadBonus = 0.0;
  }

  public Meme(float spreadBonus) {
    super();
    init();
    this.spreadBonus = spreadBonus;
  }

  private void init() {
    // size affects size of rendered image
    // appear as original size in default zoom
    size = 64; 
    numSpreaders = 0;
    spreadCount = 0;
    drawOpacity = 50;
    type = (int)random(colors.length);
    c = colors[type];
    cloudPuller = null;
  }

  public void addSpreadingCount(){
    spreadCount++;
  }

  public int getSpreadingCount(){
    return spreadCount;
  }

  public void addSpreader() {
    numSpreaders++;
  }

  public void removeSpreader(Individual who) {
    numSpreaders--;
    if(numSpreaders < 0) {
      numSpreaders = 0;
      theCloud.takeBack(this, who);
    }
  }

  public int getNumSpreaders() {
    return numSpreaders;
  }

  public void pullBack() {
    
    /*
    if(cloudPuller != null)
      cloudPuller.turnOn();

    */
  }

  public void drawMicro() {
  }

  public void drawMacro() {
    drawAt(x(), y());
  }

  public void drawAt(float x, float y) {

    tint(255, drawOpacity);

    fill(c, drawOpacity);
    noStroke();
    rectMode(CORNER);

    float offset = 5;

    rect(x-size/2+offset, y-size/2+offset, 
        size-2*offset, size-2*offset);
    image(memeImage, x-size/2, y-size/2, size, size);
    tint(255);
  }
}
